﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using XTeam.Document.Factory.ServiceInterface;
using XTeam.Documents.Business;
using XTeam.Document.Entities.Words;

namespace XTeam.Document.Services
{
    public class WordsService : IWordsService
    {
        private WordsBLL _wordsBll;
        public WordsService()
        {
            _wordsBll = new WordsBLL();
        }




        public WordsEntity FindWord(string word)
        {
            word = word.Trim();
            return _wordsBll.FindWord(word);
        }


        public int UpdateWord(WordsEntity word)
        {
            word.Word = word.Word.Trim();
            return _wordsBll.UpdateWord(word);
        }


        public int AppendWord(WordsEntity word)
        {
            word.Word = word.Word.Trim();
            return _wordsBll.AppendWord(word);
        }


        public IList<WordsEntity> Search(Func<WordsEntity, bool> filter, int pageIndex, int pageSize, out int totalRows)
        {
            pageSize = pageSize <= 0 ? 20 : pageSize;
            pageIndex = pageIndex < 1 ? 1 : pageIndex;
            return _wordsBll.Search(filter, pageIndex, pageSize, out  totalRows);
        }


        public int DelWords(string[] words)
        {
            return _wordsBll.DelWords(words);
        }


    }
}
